#pragma once
#include "ThreadObject.h"



#define SERVER_CTRL_INST ServiceHandle::Instance()
class ServiceHandle
{
    const std::string kProcessName = "QtService.exe";
public:
    static ServiceHandle& Instance()
    {
        static ServiceHandle g_inst;
        return g_inst;
    }

protected:
    ServiceHandle();
    ~ServiceHandle();

public:
    void DoClean();
    void InstallService(const std::string& strServiceName = "");
    void StartService(const std::string& strServiceName);
    void StopService(const std::string& strServiceName);
    void UninstallService(const std::string& strServiceName);
    void start();
    void pause();
    void resume();
    void stop();



private:
    void set_auto_start(const std::string& strServiceName);
    void set_failure_config(const std::string& strServiceName);
    void do_work();
    bool check_server_running(const std::string& strServiceName);
    void do_guard();
    void stop_guard();


private:
    std::string m_strServiceName;
    bool m_bRunning;
    Utils::ThreadObject m_objWork;



};
